Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[processor/transform] Unable to rename operation field #11859

Closed
klubi opened this issue Jul 1, 2022 · 7 comments
Closed

[processor/transform] Unable to rename operation field #11859

klubi opened this issue Jul 1, 2022 · 7 comments
Labels
data:traces Trace related issues processor/transform Transform processor

Comments

@klubi
Copy link

klubi commented Jul 1, 2022

Hi

I'm having an issue renaming operation field.
My simplified environment setup:

API Gateway (getambassador.io) -> otlp collector -> jaeger

API Gateway sends data in Zipkin format.
In my setup, there are plenty of subdomains and I'd like operation related field to be more generic, so in jaeger they won't be listed as separate operations, but rather be grouped.

I tried using transform processor, but wasn't able to make it work...

      transform:
        traces:
          queries:
            - replace_match(attributes["operationName"], "*.domain.com", ".{subdomain}.domain.com")
            - replace_match(attributes["name"], "*.domain.com", ".{subdomain}.domain.com")
            - replace_match(resource.attributes["operationName"], "*.domain.com", ".{subdomain}.domain.com")
            - replace_match(resource.attributes["name"], "*.domain.com", ".{subdomain}.domain.com")
@mx-psi mx-psi changed the title Unable to rename operation field [processor/transform] Unable to rename operation field Jul 1, 2022
@mx-psi mx-psi added data:traces Trace related issues processor/transform Transform processor labels Jul 1, 2022
@mx-psi
Copy link
Member

mx-psi commented Jul 1, 2022

cc @TylerHelmuth maybe you can help?

@TylerHelmuth
Copy link
Member

@klubi the replace_match function will substitute the entire string value with the replacement value if the value matches the glob pattern. So if your string is something.domain.com then the value after your repalce_match will be exactly .{subdomain}.domain.com. If you wanted to only replace the part that matches you should use replace_pattern. The results of replace_pattern would be something.{subdomain}.domain.com. The replace_pattern function will be available in the next release.

All that said, the way you have configured the processor you should at least be getting values modified to .{subdomain}.domain.com. I need more details to determine why that isn't happening. What version of the collector are you running? Do the logs show any errors? Have you confirmed that data is making it to the collector?

@klubi
Copy link
Author

klubi commented Jul 1, 2022

This is exactly what I'm looking for.
I'd like to drop that variable subdomain part, so I won't have 3k+ operations listed under api gateway service, because from backend perspective they are the same. And tracing wise they don't matter.

I'm on latest versions of collector and jaeger.

I can setup docker-compose example over weekend to demonstrate the issue.

But i guess my question boils down to: "how to reference and alter field used by jaeger to display operation name".
Using "name" and "operationName" was just a guess from my side".

@TylerHelmuth
Copy link
Member

I'm not familiar with jaeger so I won't be much help with the data once it is there.

For debugging the collector, though, enabling a logging exporter with logLevel set to Debug is a very useful way to inspect the data that would get exported to a backend. With the configuration you posted, assuming the transform processor is also added to the traces pipeline, I would expect it to be modifying all those attributes, assuming that all match the pattern.

@klubi
Copy link
Author

klubi commented Jul 1, 2022

Ok... after enabling debugging it looks like, what I'm looking for is changing span name (see span #1)
Is that even possible?

InstrumentationScope
Span #0
    Trace ID       : 716d3ffe30350813452a57bbcd810266
    Parent ID      : 452a57bbcd810266
    ID             : 227eff44e3968e25
    Name           : router cluster_qr_svc_8080_klubi egress
    Kind           : SPAN_KIND_CLIENT
    Start time     : 2022-07-01 14:55:46.349904 +0000 UTC
    End time       : 2022-07-01 14:55:46.358413 +0000 UTC
    Status code    : STATUS_CODE_UNSET
    Status message :
Attributes:
     -> upstream_address: STRING(<>:8080)
     -> component: STRING(proxy)
     -> upstream_cluster: STRING(cluster_qr_svc_8080_klubi)
     -> http.status_code: STRING(200)
     -> response_flags: STRING(-)
     -> http.protocol: STRING(HTTP/1.1)
     -> environment: STRING(dev)
Span #1
    Trace ID       : 716d3ffe30350813452a57bbcd810266
    Parent ID      :
    ID             : 452a57bbcd810266
    Name           : subdomain-1.domain.com
    Kind           : SPAN_KIND_CLIENT
    Start time     : 2022-07-01 14:55:46.349712 +0000 UTC
    End time       : 2022-07-01 14:55:46.358333 +0000 UTC
    Status code    : STATUS_CODE_UNSET
    Status message :
Attributes:
     -> node_id: STRING(test-id)
     -> guid:x-request-id: STRING(5278d94a-77a9-9c48-adf9-ef0cceacfa49)
     -> user_agent: STRING(Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36)
     -> peer.address: STRING(<>)
     -> response_size: STRING(362)
     -> http.url: STRING(https://subdomain-1.domain.com/?data=123)
     -> http.protocol: STRING(HTTP/1.1)
     -> component: STRING(proxy)
     -> http.status_code: STRING(200)
     -> http.method: STRING(GET)
     -> downstream_cluster: STRING(-)
     -> request_size: STRING(0)
     -> upstream_cluster: STRING(cluster_qr_svc_8080_klubi)
     -> response_flags: STRING(-)
     -> environment: STRING(dev)

@TylerHelmuth
Copy link
Member

Yes, you can do

transform:
  traces:
    queries:
      - replace_match(name, "*.domain.com", "{subdomain}.domain.com")

@klubi
Copy link
Author

klubi commented Jul 1, 2022

Perfect!! That worked like a charm!
Thanks a bunch.

@klubi klubi closed this as completed Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:traces Trace related issues processor/transform Transform processor
Projects
None yet
Development

No branches or pull requests

3 participants