Skip to content

Commit 82a61a1

Browse files
authored
Merge pull request #7 from Dwolla/semconv
rename attributes added by natchez-http4s to follow OTel semantic conventions
2 parents e34fee9 + 63c342d commit 82a61a1

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

otel-config.yaml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,35 @@ processors:
2323
- key: deployment.environment.name
2424
value: ${env:DWOLLA_ENV}
2525
action: insert
26-
- key: http.status_code # this is deprecated, but X-Ray wants it; see https://aws-otel.github.io/docs/getting-started/x-ray#otel-span-http-attributes-translation
26+
27+
# rename attributes to follow OTel semantic conventions
28+
- key: url.full
29+
action: insert
30+
# from https://github.com/typelevel/natchez-http4s/blob/168f5031323a573b5641f43c74a25d1a996f7b61/modules/http4s/src/main/scala/natchez/http4s/NatchezMiddleware.scala#L176
31+
from_attribute: client.http.uri
32+
- key: http.request.method
33+
action: insert
34+
# from https://github.com/typelevel/natchez-http4s/blob/168f5031323a573b5641f43c74a25d1a996f7b61/modules/http4s/src/main/scala/natchez/http4s/NatchezMiddleware.scala#L177
35+
from_attribute: client.http.method
36+
- key: http.response.status_code
37+
action: insert
38+
# from https://github.com/typelevel/natchez-http4s/blob/168f5031323a573b5641f43c74a25d1a996f7b61/modules/http4s/src/main/scala/natchez/http4s/NatchezMiddleware.scala#L183
39+
from_attribute: client.http.status_code
40+
- key: http.response.status_code
2741
action: insert
28-
from_attribute: http.response.status_code
42+
# from https://github.com/typelevel/natchez-http4s/blob/168f5031323a573b5641f43c74a25d1a996f7b61/modules/http4s/src/main/scala/natchez/http4s/NatchezMiddleware.scala#L58
43+
from_attribute: http.status_code
44+
# remove the attributes we copied to complete the renaming
45+
- action: delete
46+
pattern: client\.http\.uri|client\.http\.method|(?:client\.)?http\.status_code
47+
transform/status-code-is-int:
48+
# Natchez-http4s sets http.response.status_code as a string, but the OTel semantic
49+
# conventions define it as an int, and X-Ray won't display it otherwise.
50+
# see https://github.com/typelevel/natchez-http4s/blob/168f5031323a573b5641f43c74a25d1a996f7b61/modules/http4s/src/main/scala/natchez/http4s/NatchezMiddleware.scala#L183
51+
trace_statements:
52+
- context: span
53+
statements:
54+
- set(attributes["http.response.status_code"], Int(attributes["http.response.status_code"]))
2955
transform/replace-exclamation-with-colon:
3056
trace_statements:
3157
- context: span

0 commit comments

Comments
 (0)