Skip to content

Commit b0fed33

Browse files
committed
bring up a test env frictionless
Signed-off-by: Harshil Gupta <[email protected]>
1 parent e5db717 commit b0fed33

File tree

3 files changed

+23
-128
lines changed

3 files changed

+23
-128
lines changed

docker-compose/monitor/TAG_FILTERING.md

Lines changed: 10 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -32,49 +32,22 @@ and API, just like they can filter traces.
3232
connectors:
3333
spanmetrics:
3434
dimensions:
35-
# Regular dimensions
3635
- name: operation
3736
default: unknown-operation
38-
# Tag dimensions
39-
- name: tag1
40-
default: ""
41-
- name: tag2
37+
# Add tag dimensions for filtering
38+
- name: env
4239
default: ""
4340

4441
# Use the attributes processor to propagate tags
4542
processors:
4643
attributes:
4744
actions:
48-
- key: tag1
45+
# Copy resource attributes to span attributes for metrics filtering
46+
- key: env
4947
action: insert
50-
value: "value1" # In production, use dynamic values if supported
48+
from_attribute: env
5149
```
5250
53-
### Version Compatibility
54-
55-
The configuration may need adjustments based on your OpenTelemetry Collector version:
56-
57-
- **Older versions**: Use the approach shown here with the attributes processor
58-
- **Newer versions (0.83.0+)**: May support direct resource attribute propagation with options like
59-
`resource_metrics_strategy` and `resource_attributes`
60-
61-
Note: Even though your go.mod file may show a newer version of the collector, the Docker image used might
62-
have an older version of the spanmetrics connector that doesn't support these newer features.
63-
64-
## Implementation Hack
65-
66-
The current implementation uses a workaround to enable tag filtering in metrics:
67-
68-
1. **Fixed Tag Values**: Since older collector versions can't dynamically propagate resource attributes to span metrics dimensions, we use the attributes processor to insert fixed tag values (e.g., "value1", "value2").
69-
70-
2. **Manual Configuration**: For each tag you want to filter by, you need to:
71-
- Add it as a dimension in the spanmetrics connector
72-
- Create an attributes processor action to insert it as a span attribute
73-
74-
3. **Limited Tag Values**: This approach only works with known, pre-configured tag values. If you need to support arbitrary tag values, you'll need to upgrade to a newer collector version that supports resource attribute propagation.
75-
76-
4. **Testing Workflow**: When testing, send traces with the exact tag values configured in the attributes processor, as these are the only values that will work with the filtering.
77-
7851
## Example Usage
7952
8053
To test tag filtering:
@@ -91,56 +64,19 @@ http://localhost:16686/api/metrics/calls?service=my-service&tag=tag1:value1
9164
## Testing with Docker Compose
9265

9366
To test tag filtering in the Docker Compose environment:
94-
95-
1. **Use the provided configuration**: Ensure you're using `config-spm-with-tag-filtering.yaml`
96-
```yaml
97-
# In docker-compose.yml
98-
volumes:
99-
- "../../cmd/jaeger/config-spm-with-tag-filtering.yaml:/etc/jaeger/config.yml"
100-
```
101-
102-
2. **Generate test traces with matching tags**: Send traces with resource attributes matching the configured tag values
103-
```bash
104-
docker run --env OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="http://jaeger:4318/v1/traces" \
105-
--env OTEL_RESOURCE_ATTRIBUTES="tag1=value1,tag2=value2" \
106-
--network monitor_backend \
107-
--rm \
108-
jaegertracing/jaeger-tracegen:latest \
109-
-trace-exporter otlp-http \
110-
-service tag-filtering-demo \
111-
-traces 10
112-
```
113-
67+
1. Start the docker compose file for tag filtering [docker-compose-tag-filtering.yml](./docker-compose-tag-filtering.yml)
68+
2. This will start jaeger, prometheus, and two trace generator which generate traces from staging and production envs.
11469
3. **Query metrics with tag filters**: Use the metrics API with tag filter parameters
11570
```bash
116-
curl "http://localhost:16686/api/metrics/calls?service=tag-filtering-demo&tag=tag1:value1" | jq '.'
71+
curl "http://localhost:16686/api/metrics/errors?service=redis&endTs=1755599476047&lookback=300000&quantile=0.95&ratePer=600000&spanKind=server&step=60000&tag=env:staging" | jq
11772
```
11873

119-
The key to this hack is ensuring that the fixed values in your configuration (`value1`, `value2`) match the values in your resource attributes when generating traces.
120-
12174
## Debugging Tips
12275

12376
If tag filtering isn't working as expected:
12477

125-
1. **Check Prometheus metrics**: Verify that metrics include the tag labels
78+
1. Metrics might take some time to appear, ~1min
79+
2. **Check Prometheus metrics**: Verify that metrics include the tag labels
12680
```bash
12781
curl "http://localhost:9090/api/v1/query?query=traces_span_metrics_calls_total{tag1='value1'}"
12882
```
129-
130-
2. **Verify collector configuration**: Ensure the spanmetrics connector is correctly configured with `resource_metrics_strategy` and the appropriate `resource_attributes`
131-
132-
3. **Inspect resource attributes**: Use the Jaeger UI to check if spans have the expected resource attributes
133-
134-
4. **Common issues**:
135-
- Missing resource attributes in the `resource_attributes` list
136-
- Incorrect pipeline configuration
137-
- Resource attributes not properly set when generating traces
138-
139-
## Limitations
140-
141-
This approach has several limitations:
142-
143-
1. **Fixed values only**: Only works with predefined tag values; can't handle arbitrary user-defined tag values
144-
2. **Manual configuration**: Requires manual updates to add new tags or tag values
145-
3. **Resource overhead**: Less efficient than native resource attribute propagation
146-
4. **Maintenance complexity**: Configuration becomes more complex as you add more tags

docker-compose/monitor/docker-compose-tag-filtering.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,25 @@ services:
1616
- "4317:4317"
1717
- "4318:4318"
1818

19-
microsim:
19+
microsim-prouction:
2020
networks:
2121
- backend
2222
image: yurishkuro/microsim:v0.5.0@sha256:b7ee2dee51d2c9fd94de08a80278cfbf5a144ad0f22efce50f3d3be15cbfa2c7
2323
command: "-d 24h -s 500ms"
2424
environment:
2525
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://jaeger:4318/v1/traces
26+
- OTEL_RESOURCE_ATTRIBUTES=env=production
27+
depends_on:
28+
- jaeger
29+
30+
microsim-staging:
31+
networks:
32+
- backend
33+
image: yurishkuro/microsim:v0.5.0@sha256:b7ee2dee51d2c9fd94de08a80278cfbf5a144ad0f22efce50f3d3be15cbfa2c7
34+
command: "-d 24h -s 500ms"
35+
environment:
36+
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://jaeger:4318/v1/traces
37+
- OTEL_RESOURCE_ATTRIBUTES=env=staging
2638
depends_on:
2739
- jaeger
2840

docker-compose/monitor/test-tag-filtering.sh

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)