-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Support regex matching against values in attributesprocessor #979
Comments
To address this comment https://github.com/open-telemetry/opentelemetry-collector/pull/981/files#r426882973 in #981 I propose changing the configuration to look like
Resulting in sample configs:
cc @bogdandrutu and @tigrannajaryan for thoughts. |
We've discussed doing something like this in the filtering proposal where the action (match type) is a key. Also is doing key/value necessary or can it use a regular yaml map? I don't think you'd ever be inserting into the same key would you? For instance, an alternative to the above config: attributes:
insert:
"http.url":
regex: ^(?P<http_protocol>.*):\/\/(?P<http_domain>.*)\/(?P<http_path>.*)(\?|\&)(?P<http_query_params>.*)
"string key":
from_attribute: "anotherkey" Edit: removed |
Also we're adding support for nested arrays and maps in attributes to the protocol. If we're going to redesign the config do we need to go ahead and take that into account? It's starting to hurt my brain given attributes can be arbitrarily nested.. |
I feel like once we start going down the nested array/map hole things could get complicated trying to express it in yaml. Maybe we just need a small DSL. (Actually, maybe just borrow Python syntax entirely, but it wouldn't be implemented in Python): # Delete nested
del attr["foo"]["bar"]
# Add dictionary
attr["bar"] = {"one": "two"}
# Overwrite list
attr["list"] = [1,2,3]
# Append to list
attr["list"] += [4,5,6]
# regex
attr["http.url"] = /^(?P<http_protocol>.*):\/\/(?P<http_domain>.*)\/(?P<http_path>.*)(\?|\&)(?P<http_query_params>.*)/
# from another key
attr["string key"] = attr["another key"] Obviously the operations it can do would be fairly limited but I think it's going to be way easier to understand than more yaml. |
Note: All of the cudos go to @dneray for the logic/testing/effort in #981 This pr is based off of it with the following modifications - The config looks like ``` - key : <key to use for applying the rule too> pattern: <the regex pattern with named submatchers> action: extract ``` I think that the original PR is going in the right way for what we can the internal logic to be but as the issue #979 and #1170 indicate we need to take a step back and redesign the attributes processor (or make it clear of its limitations). This pr unblocks the required functionality. **Link to tracking Issue:** #979 **Link to follow up issue:** #1170 **Testing:** Added tests for extracting. **Documentation:** Updated processor readme.
Note: All of the cudos go to @dneray for the logic/testing/effort in open-telemetry#981 This pr is based off of it with the following modifications - The config looks like ``` - key : <key to use for applying the rule too> pattern: <the regex pattern with named submatchers> action: extract ``` I think that the original PR is going in the right way for what we can the internal logic to be but as the issue open-telemetry#979 and open-telemetry#1170 indicate we need to take a step back and redesign the attributes processor (or make it clear of its limitations). This pr unblocks the required functionality. **Link to tracking Issue:** open-telemetry#979 **Link to follow up issue:** open-telemetry#1170 **Testing:** Added tests for extracting. **Documentation:** Updated processor readme.
To wrap up this issue - regex support is in the attributes processor. The follow up questions around supporting new data types for the processor and coming up with a more comprehensive configuration is tracked by #1170 |
http.ResponseWriters may implement additional interfaces (http.CloseNotifier, http.Flusher, http.Hijacker, http.Pusher, io.ReaderFrom) that get lost when the ResponseWriter is wrapped in another object. This change uses the httpsnoop package to wrap the ResponseWriter so that the resulting object implements any of the optional interfaces that the original ResponseWriter implements as well as using the replacement ResponseWriter methods that gather information for tracing.
I have some use cases where it would be useful to be able to parse the attribute values into multiple fields.
For example my application has a field
http.url: http://example.com/path?queryParam1=value1,queryParam2=value2
and I would like to parse out the fields into:
http_protocol: http
http_domain: example.com
http_path: path
http_query_params: queryParam1=value1,queryParam2=value2
This is what I am thinking for the configuration:
The text was updated successfully, but these errors were encountered: