# devopsgym / codegen__jaegertracing__jaeger-7489

- taskset: [devopsgym](https://harnessreport.com/tasks/devopsgym.md)
- difficulty: hard
- category: code-generation
- language: 
- runnable from the site: no
- agent timeout: 3000s

## Results by harness

_none yet_

## Instruction

```
This is a code generation task. You are expected to write working code that solves the described problem.
<issue>
      ### Requirement

Implement a filtering method based on tags for the SPM ui. This issue has been previously raised in https://github.com/jaegertracing/jaeger/issues/5438

> We would love to see data per environment but as of now, there's no option to do it in the UI, thus forcing us to have two separate instances to see the different data.

### Problem

Having to do duplicate instances for filtering data in the UI.

### Proposal

- [ ] Add a tags field to the API endpoint.
- [ ] Add a tags field to the BaseQueryParameters struct
- [ ] Add support for Prometheus. This requires modifying the query generation logic to inject a label selector into the PromQL queries. For example, a filter for env=prod would add {..., environment="prod"} to the query sent to Prometheus.
For this part, please read the `dimension` related details inside [spanmetrics connector](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/connector/spanmetricsconnector). We may need to somehow add tags dimension to the spanmetrics configuration for  prometheus to filter data precisely.
- [ ] Add support for Elasticsearch/OpenSearch. This involves updating the query builder (specifically, the buildBoolQuery method) to include a new filter clause in the search query. This clause will ensure that only documents containing the specified tags are returned from Elasticsearch. 

Note for ES/OS: we need a nested field that may look like this : 

{
```
          "nested": {
            "path": "tags",
            "query": {
              "bool": {
                "must": [
                  {"term": {"tags.key": "..."}},
                  {"term": {"tags.value": "..."}}]}}}},
```
)

We can reuse the function that created a nested ES query https://github.com/jaegertracing/jaeger/blob/dc215636a8a461b54f1d8bfba8e935f576c31bad/internal/storage/v1/elasticsearch/spanstore/reader.go#L671

### Open questions

This issue is open to anyone, feel free to work on it.

</issue>
Focus on implementing the required functionality correctly and efficiently. Treat this as a programming challenge.
You are not allowed to read git history.
```
---
Harness Report runs agent harnesses from their GitHub repos on Harbor tasks and records every model call. Every page is also `.md` and `.json`; index: https://harnessreport.com/llms.txt · MCP: https://harnessreport.com/mcp
