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

[pkg/ottl] parse uri string to url.* SemConv attributes #32906

Merged
merged 61 commits into from
Jun 17, 2024

Conversation

michalpristas
Copy link
Contributor

@michalpristas michalpristas commented May 7, 2024

Description:
This ottl converter converts uri string into SemConv attributes.
Instead of using regex it uses uri.Parse providing nicer shorthand.

Link to tracking Issue: #32433

Testing: unit test added

Documentation: readme updated with:

Uri

Uri(uri_string)

Parses a Uniform Resource Identifier (URI) string and extracts its components as an object.
This URI object includes properties for the URI’s domain, path, fragment, port, query, scheme, user info, username, and password.

original, domain, scheme and path are always present, other are present only if they have corresponding values.

uri_string is a string.

  • Uri("http://www.example.com")

results in

  "original": "http://www.example.com",
  "scheme":   "http",
  "domain":   "www.example.com",
  "path":     "",

results in

  "path":      "/foo.gif",
  "fragment":  "fragment",
  "extension": "gif",
  "password":  "mypassword",
  "original":  "http://myusername:[email protected]:80/foo.gif?key1=val1&key2=val2#fragment",
  "scheme":    "http",
  "port":      80,
  "user_info": "myusername:mypassword",
  "domain":    "www.example.com",
  "query":     "key1=val1&key2=val2",
  "username":  "myusername",

@michalpristas michalpristas changed the title Parse uri string to url.* SemConv attributes [pkg/ottl] parse uri string to url.* SemConv attributes May 9, 2024
pkg/ottl/ottlfuncs/README.md Outdated Show resolved Hide resolved
pkg/ottl/ottlfuncs/func_uri.go Outdated Show resolved Hide resolved
@michalpristas
Copy link
Contributor Author

@djaglowski i moved implementation of the uri parser to stanza uri parser with a conditional for current behavior and new semconv aligned behavior. please let me know if this is ok or we should extract even more outside

@djaglowski
Copy link
Member

@djaglowski i moved implementation of the uri parser to stanza uri parser with a conditional for current behavior and new semconv aligned behavior. please let me know if this is ok or we should extract even more outside

The implementation looks good to me but in the past we've avoided making ottl dependent on stanza by moving code to a shared package. e.g. https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/internal/coreinternal/parseutils

@michalpristas
Copy link
Contributor Author

will move it somewhere there, thanks

@michalpristas
Copy link
Contributor Author

@djaglowski moved it to coreinternal hope it's better now

pkg/ottl/ottlfuncs/func_uri.go Outdated Show resolved Hide resolved
pkg/ottl/ottlfuncs/README.md Outdated Show resolved Hide resolved
pkg/ottl/ottlfuncs/README.md Outdated Show resolved Hide resolved
pkg/stanza/operator/parser/uri/parser.go Outdated Show resolved Hide resolved
@djaglowski djaglowski merged commit 6f30561 into open-telemetry:main Jun 17, 2024
153 of 154 checks passed
@github-actions github-actions bot added this to the next release milestone Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmd/githubgen cmd/opampsupervisor cmd/otelcontribcol otelcontribcol command cmd/oteltestbedcol cmd/telemetrygen telemetrygen command confmap/provider/s3provider confmap/provider/secretsmanagerprovider connector/count connector/datadog connector/exceptions connector/failover connector/grafanacloud connector/roundrobin connector/routing connector/servicegraph connector/spanmetrics exporter/alertmanager exporter/alibabacloudlogservice Alibaba components exporter/awscloudwatchlogs awscloudwatchlogs exporter exporter/awsemf awsemf exporter exporter/awskinesis exporter/awss3 exporter/awsxray exporter/azuredataexplorer exporter/azuremonitor exporter/carbon exporter/cassandra exporter/clickhouse exporter/coralogix exporter/datadog Datadog components exporter/dataset exporter/elasticsearch exporter/file exporter/googlecloud exporter/googlecloudpubsub exporter/googlemanagedprometheus Google Managed Prometheus exporter exporter/honeycombmarker exporter/influxdb exporter/instana exporter/kafka exporter/kinetica exporter/loadbalancing exporter/logicmonitor exporter/logzio exporter/loki Loki Exporter exporter/mezmo exporter/opencensus exporter/opensearch exporter/otelarrow exporter/prometheus exporter/prometheusremotewrite exporter/pulsar exporter/rabbitmq exporter/sapm exporter/sentry exporter/signalfx exporter/skywalking exporter/splunkhec exporter/sumologic exporter/syslog exporter/tencentcloudlogservice exporter/zipkin extension/ack extension/asapauth extension/awsproxy extension/basicauth extension/bearertokenauth extension/encoding extension/googleclientauth extension/headerssetter extension/healthcheck Health Check Extension extension/healthcheckv2 extension/httpforwarder extension/jaegerremotesampling extension/oauth2clientauth extension/observer extension/oidcauth extension/opamp extension/pprof extension/remotetap extension/sigv4auth extension/solarwindsapmsettings extension/storage internal/core pkg/ottl pkg/stanza processor/logstransform Logs Transform processor processor/routing Routing processor processor/tailsampling Tail sampling processor processor/transform Transform processor receiver/filelog receiver/journald receiver/mongodbatlas receiver/namedpipe receiver/otlpjsonfile receiver/sqlquery SQL query receiver receiver/syslog receiver/tcplog receiver/udplog receiver/windowseventlog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants