Skip to content

Commit 34f72d1

Browse files
authored
[processor/geoip] Align with semconv resource attributes (open-telemetry#41044)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description This PR changes the resource attributes keys added by the processor with the ones matching in Semantic Conventions. There are three breaking changes in terms of the resource attribute key names: `geo.continent.code`, `geo.country.iso_code` and `geo.region.iso_code`. <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes open-telemetry#34745 <!--Describe what testing was performed and which tests were added.--> #### Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.-->
1 parent 7204540 commit 34f72d1

File tree

15 files changed

+118
-89
lines changed

15 files changed

+118
-89
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: geoipprocessor
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Use semantic convention Geo attributes
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [34745]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: |
19+
Replace `geo.continent_code`, `geo.country_iso_code`, `geo.region_iso_code`
20+
with semantic conventions `geo.continent.code`, `geo.country.iso_code`, `geo.region.iso_code`
21+
attributes.
22+
23+
# If your change doesn't affect end users or the exported elements of any package,
24+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
25+
# Optional: The change log or logs in which this entry should be included.
26+
# e.g. '[user]' or '[user, api]'
27+
# Include 'user' if the change is relevant to end users.
28+
# Include 'api' if there is a change to a library API.
29+
# Default: '[user]'
30+
change_logs: []

processor/geoipprocessor/README.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,17 @@ The geoIP processor `geoipprocessor` enhances the attributes of a span, log, or
2121

2222
The following [resource attributes](./internal/convention/attributes.go) will be added if the corresponding information is found:
2323

24-
```
25-
* geo.city_name
26-
* geo.postal_code
27-
* geo.country_name
28-
* geo.country_iso_code
29-
* geo.continent_name
30-
* geo.continent_code
31-
* geo.region_name
32-
* geo.region_iso_code
33-
* geo.timezone
34-
* geo.location.lat
35-
* geo.location.lon
36-
```
24+
- geo.city_name
25+
- [geo.postal_code](https://github.com/open-telemetry/semantic-conventions/blob/v1.34.0/model/geo/registry.yaml#L71)
26+
- geo.country_name
27+
- [geo.country.iso_code](https://github.com/open-telemetry/semantic-conventions/blob/v1.34.0/model/geo/registry.yaml#L53)
28+
- geo.continent_name
29+
- [geo.continent.code](https://github.com/open-telemetry/semantic-conventions/blob/v1.34.0/model/geo/registry.yaml#L19)
30+
- geo.region_name
31+
- [geo.region.iso_code](https://github.com/open-telemetry/semantic-conventions/blob/v1.34.0/model/geo/registry.yaml#L78)
32+
- geo.timezone
33+
- [geo.location.lat](https://github.com/open-telemetry/semantic-conventions/blob/v1.34.0/model/geo/registry.yaml#L65)
34+
- [geo.location.lon](https://github.com/open-telemetry/semantic-conventions/blob/v1.34.0/model/geo/registry.yaml#L59)
3735

3836
## Configuration
3937

processor/geoipprocessor/internal/convention/attributes.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,39 @@
33

44
package conventions // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/geoipprocessor/internal/convention"
55

6-
// TODO: replace for semconv once https://github.com/open-telemetry/semantic-conventions/issues/1033 is closed.
6+
import semconv "go.opentelemetry.io/otel/semconv/v1.34.0"
7+
78
const (
89
// AttributeGeoCityName represents the attribute name for the city name in geographical data.
910
AttributeGeoCityName = "geo.city_name"
1011

1112
// AttributeGeoPostalCode represents the attribute name for the city postal code.
12-
AttributeGeoPostalCode = "geo.postal_code"
13+
AttributeGeoPostalCode = string(semconv.GeoPostalCodeKey)
1314

1415
// AttributeGeoCountryName represents the attribute name for the country name in geographical data.
1516
AttributeGeoCountryName = "geo.country_name"
1617

1718
// AttributeGeoCountryIsoCode represents the attribute name for the Two-letter ISO Country Code.
18-
AttributeGeoCountryIsoCode = "geo.country_iso_code"
19+
AttributeGeoCountryIsoCode = string(semconv.GeoCountryISOCodeKey)
1920

2021
// AttributeGeoContinentName represents the attribute name for the continent name in geographical data.
2122
AttributeGeoContinentName = "geo.continent_name"
2223

2324
// AttributeGeoContinentIsoCode represents the attribute name for the Two-letter Continent Code.
24-
AttributeGeoContinentCode = "geo.continent_code"
25+
AttributeGeoContinentCode = string(semconv.GeoContinentCodeKey)
2526

2627
// AttributeGeoRegionName represents the attribute name for the region name in geographical data.
2728
AttributeGeoRegionName = "geo.region_name"
2829

2930
// AttributeGeoRegionIsoCode represents the attribute name for the Two-letter ISO Region Code.
30-
AttributeGeoRegionIsoCode = "geo.region_iso_code"
31+
AttributeGeoRegionIsoCode = string(semconv.GeoRegionISOCodeKey)
3132

3233
// AttributeGeoTimezone represents the attribute name for the timezone.
3334
AttributeGeoTimezone = "geo.timezone"
3435

3536
// AttributeGeoLocationLat represents the attribute name for the latitude.
36-
AttributeGeoLocationLat = "geo.location.lat"
37+
AttributeGeoLocationLat = string(semconv.GeoLocationLatKey)
3738

3839
// AttributeGeoLocationLon represents the attribute name for the longitude.
39-
AttributeGeoLocationLon = "geo.location.lon"
40+
AttributeGeoLocationLon = string(semconv.GeoLocationLonKey)
4041
)

processor/geoipprocessor/testdata/record_client_address/output-logs.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ resourceLogs:
1919
- key: geo.city_name
2020
value:
2121
stringValue: Boxford
22-
- key: geo.continent_code
22+
- key: geo.continent.code
2323
value:
2424
stringValue: EU
2525
- key: geo.continent_name
2626
value:
2727
stringValue: Europe
28-
- key: geo.country_iso_code
28+
- key: geo.country.iso_code
2929
value:
3030
stringValue: GB
3131
- key: geo.country_name
@@ -40,7 +40,7 @@ resourceLogs:
4040
- key: geo.postal_code
4141
value:
4242
stringValue: OX1
43-
- key: geo.region_iso_code
43+
- key: geo.region.iso_code
4444
value:
4545
stringValue: WBK
4646
- key: geo.region_name

processor/geoipprocessor/testdata/record_client_address/output-metrics.yaml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,19 @@ resourceMetrics:
1717
- key: a
1818
value:
1919
stringValue: AAAA
20+
- key: client.address
21+
value:
22+
stringValue: 1.2.3.4
2023
- key: geo.city_name
2124
value:
2225
stringValue: Boxford
23-
- key: geo.continent_code
26+
- key: geo.continent.code
2427
value:
2528
stringValue: EU
2629
- key: geo.continent_name
2730
value:
2831
stringValue: Europe
29-
- key: geo.country_iso_code
32+
- key: geo.country.iso_code
3033
value:
3134
stringValue: GB
3235
- key: geo.country_name
@@ -41,7 +44,7 @@ resourceMetrics:
4144
- key: geo.postal_code
4245
value:
4346
stringValue: OX1
44-
- key: geo.region_iso_code
47+
- key: geo.region.iso_code
4548
value:
4649
stringValue: WBK
4750
- key: geo.region_name
@@ -50,24 +53,24 @@ resourceMetrics:
5053
- key: geo.timezone
5154
value:
5255
stringValue: Europe/London
53-
- key: client.address
54-
value:
55-
stringValue: 1.2.3.4
5656
unit: "1"
5757
- histogram:
5858
aggregationTemporality: 1
5959
dataPoints:
6060
- attributes:
61+
- key: client.address
62+
value:
63+
stringValue: 1.2.3.4
6164
- key: geo.city_name
6265
value:
6366
stringValue: Boxford
64-
- key: geo.continent_code
67+
- key: geo.continent.code
6568
value:
6669
stringValue: EU
6770
- key: geo.continent_name
6871
value:
6972
stringValue: Europe
70-
- key: geo.country_iso_code
73+
- key: geo.country.iso_code
7174
value:
7275
stringValue: GB
7376
- key: geo.country_name
@@ -82,7 +85,7 @@ resourceMetrics:
8285
- key: geo.postal_code
8386
value:
8487
stringValue: OX1
85-
- key: geo.region_iso_code
88+
- key: geo.region.iso_code
8689
value:
8790
stringValue: WBK
8891
- key: geo.region_name
@@ -91,9 +94,6 @@ resourceMetrics:
9194
- key: geo.timezone
9295
value:
9396
stringValue: Europe/London
94-
- key: client.address
95-
value:
96-
stringValue: 1.2.3.4
9797
bucketCounts:
9898
- "9"
9999
- "12"
@@ -112,16 +112,19 @@ resourceMetrics:
112112
summary:
113113
dataPoints:
114114
- attributes:
115+
- key: client.address
116+
value:
117+
stringValue: 1.2.3.4
115118
- key: geo.city_name
116119
value:
117120
stringValue: Boxford
118-
- key: geo.continent_code
121+
- key: geo.continent.code
119122
value:
120123
stringValue: EU
121124
- key: geo.continent_name
122125
value:
123126
stringValue: Europe
124-
- key: geo.country_iso_code
127+
- key: geo.country.iso_code
125128
value:
126129
stringValue: GB
127130
- key: geo.country_name
@@ -136,7 +139,7 @@ resourceMetrics:
136139
- key: geo.postal_code
137140
value:
138141
stringValue: OX1
139-
- key: geo.region_iso_code
142+
- key: geo.region.iso_code
140143
value:
141144
stringValue: WBK
142145
- key: geo.region_name
@@ -145,9 +148,6 @@ resourceMetrics:
145148
- key: geo.timezone
146149
value:
147150
stringValue: Europe/London
148-
- key: client.address
149-
value:
150-
stringValue: 1.2.3.4
151151
quantileValues:
152152
- quantile: 0.25
153153
value: 50
@@ -165,16 +165,19 @@ resourceMetrics:
165165
- key: aaa
166166
value:
167167
stringValue: bbb
168+
- key: client.address
169+
value:
170+
stringValue: 1.2.3.4
168171
- key: geo.city_name
169172
value:
170173
stringValue: Boxford
171-
- key: geo.continent_code
174+
- key: geo.continent.code
172175
value:
173176
stringValue: EU
174177
- key: geo.continent_name
175178
value:
176179
stringValue: Europe
177-
- key: geo.country_iso_code
180+
- key: geo.country.iso_code
178181
value:
179182
stringValue: GB
180183
- key: geo.country_name
@@ -189,7 +192,7 @@ resourceMetrics:
189192
- key: geo.postal_code
190193
value:
191194
stringValue: OX1
192-
- key: geo.region_iso_code
195+
- key: geo.region.iso_code
193196
value:
194197
stringValue: WBK
195198
- key: geo.region_name
@@ -198,9 +201,6 @@ resourceMetrics:
198201
- key: geo.timezone
199202
value:
200203
stringValue: Europe/London
201-
- key: client.address
202-
value:
203-
stringValue: 1.2.3.4
204204
timeUnixNano: "1000000"
205205
name: test.gauge
206206
schemaUrl: https://test-scope-schema.com/schema

processor/geoipprocessor/testdata/record_client_address/output-traces.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ resourceSpans:
2222
- key: geo.city_name
2323
value:
2424
stringValue: Boxford
25-
- key: geo.continent_code
25+
- key: geo.continent.code
2626
value:
2727
stringValue: EU
2828
- key: geo.continent_name
2929
value:
3030
stringValue: Europe
31-
- key: geo.country_iso_code
31+
- key: geo.country.iso_code
3232
value:
3333
stringValue: GB
3434
- key: geo.country_name
@@ -43,7 +43,7 @@ resourceSpans:
4343
- key: geo.postal_code
4444
value:
4545
stringValue: OX1
46-
- key: geo.region_iso_code
46+
- key: geo.region.iso_code
4747
value:
4848
stringValue: WBK
4949
- key: geo.region_name

processor/geoipprocessor/testdata/record_custom_address/output-logs.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ resourceLogs:
1919
- key: geo.city_name
2020
value:
2121
stringValue: Boxford
22-
- key: geo.continent_code
22+
- key: geo.continent.code
2323
value:
2424
stringValue: EU
2525
- key: geo.continent_name
2626
value:
2727
stringValue: Europe
28-
- key: geo.country_iso_code
28+
- key: geo.country.iso_code
2929
value:
3030
stringValue: GB
3131
- key: geo.country_name
@@ -40,7 +40,7 @@ resourceLogs:
4040
- key: geo.postal_code
4141
value:
4242
stringValue: OX1
43-
- key: geo.region_iso_code
43+
- key: geo.region.iso_code
4444
value:
4545
stringValue: WBK
4646
- key: geo.region_name

processor/geoipprocessor/testdata/record_custom_address/output-metrics.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ resourceMetrics:
1111
dataPoints:
1212
- asDouble: 345
1313
attributes:
14-
- key: custom.address
15-
value:
16-
stringValue: 1.2.3.4
1714
- key: aaa
1815
value:
1916
stringValue: bbb
17+
- key: custom.address
18+
value:
19+
stringValue: 1.2.3.4
2020
- key: geo.city_name
2121
value:
2222
stringValue: Boxford
23-
- key: geo.continent_code
23+
- key: geo.continent.code
2424
value:
2525
stringValue: EU
2626
- key: geo.continent_name
2727
value:
2828
stringValue: Europe
29-
- key: geo.country_iso_code
29+
- key: geo.country.iso_code
3030
value:
3131
stringValue: GB
3232
- key: geo.country_name
@@ -41,7 +41,7 @@ resourceMetrics:
4141
- key: geo.postal_code
4242
value:
4343
stringValue: OX1
44-
- key: geo.region_iso_code
44+
- key: geo.region.iso_code
4545
value:
4646
stringValue: WBK
4747
- key: geo.region_name

0 commit comments

Comments
 (0)