Skip to content

Commit 37586c5

Browse files
committed
Renamed keys to make ingestion possible
1 parent 5d49e4a commit 37586c5

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

sentry_sdk/integrations/cloud_resource_context.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ def _is_aws(cls):
9090
def _get_aws_context(cls):
9191
# type: () -> Dict[str, str]
9292
ctx = {
93-
"cloud.provider": CLOUD_PROVIDER.AWS,
94-
"cloud.platform": CLOUD_PLATFORM.AWS_EC2,
93+
"cloud_provider": CLOUD_PROVIDER.AWS,
94+
"cloud_platform": CLOUD_PLATFORM.AWS_EC2,
9595
}
9696

9797
try:
@@ -107,27 +107,27 @@ def _get_aws_context(cls):
107107
data = json.loads(r.data.decode("utf-8"))
108108

109109
try:
110-
ctx["cloud.account.id"] = data["accountId"]
110+
ctx["cloud_account_id"] = data["accountId"]
111111
except Exception:
112112
pass
113113

114114
try:
115-
ctx["cloud.availability_zone"] = data["availabilityZone"]
115+
ctx["cloud_availability_zone"] = data["availabilityZone"]
116116
except Exception:
117117
pass
118118

119119
try:
120-
ctx["cloud.region"] = data["region"]
120+
ctx["cloud_region"] = data["region"]
121121
except Exception:
122122
pass
123123

124124
try:
125-
ctx["host.id"] = data["instanceId"]
125+
ctx["host_id"] = data["instanceId"]
126126
except Exception:
127127
pass
128128

129129
try:
130-
ctx["host.type"] = data["instanceType"]
130+
ctx["host_type"] = data["instanceType"]
131131
except Exception:
132132
pass
133133

@@ -159,8 +159,8 @@ def _is_gcp(cls):
159159
def _get_gcp_context(cls):
160160
# type: () -> Dict[str, str]
161161
ctx = {
162-
"cloud.provider": CLOUD_PROVIDER.GCP,
163-
"cloud.platform": CLOUD_PLATFORM.GCP_COMPUTE_ENGINE,
162+
"cloud_provider": CLOUD_PROVIDER.GCP,
163+
"cloud_platform": CLOUD_PLATFORM.GCP_COMPUTE_ENGINE,
164164
}
165165

166166
try:
@@ -177,27 +177,27 @@ def _get_gcp_context(cls):
177177
cls.gcp_metadata = json.loads(r.data.decode("utf-8"))
178178

179179
try:
180-
ctx["cloud.account.id"] = cls.gcp_metadata["project"]["projectId"]
180+
ctx["cloud_account_id"] = cls.gcp_metadata["project"]["projectId"]
181181
except Exception:
182182
pass
183183

184184
try:
185-
ctx["cloud.availability_zone"] = cls.gcp_metadata["instance"][
185+
ctx["cloud_availability_zone"] = cls.gcp_metadata["instance"][
186186
"zone"
187187
].split("/")[-1]
188188
except Exception:
189189
pass
190190

191191
try:
192192
# only populated in google cloud run
193-
ctx["cloud.region"] = cls.gcp_metadata["instance"]["region"].split("/")[
193+
ctx["cloud_region"] = cls.gcp_metadata["instance"]["region"].split("/")[
194194
-1
195195
]
196196
except Exception:
197197
pass
198198

199199
try:
200-
ctx["host.id"] = cls.gcp_metadata["instance"]["id"]
200+
ctx["host_id"] = cls.gcp_metadata["instance"]["id"]
201201
except Exception:
202202
pass
203203

tests/integrations/cloud_resource_context/test_cloud_resource_context.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -142,29 +142,29 @@ def test_is_aw_exception():
142142
405,
143143
b"",
144144
{
145-
"cloud.provider": CLOUD_PROVIDER.AWS,
146-
"cloud.platform": CLOUD_PLATFORM.AWS_EC2,
145+
"cloud_provider": CLOUD_PROVIDER.AWS,
146+
"cloud_platform": CLOUD_PLATFORM.AWS_EC2,
147147
},
148148
],
149149
[
150150
200,
151151
b"something-but-not-json",
152152
{
153-
"cloud.provider": CLOUD_PROVIDER.AWS,
154-
"cloud.platform": CLOUD_PLATFORM.AWS_EC2,
153+
"cloud_provider": CLOUD_PROVIDER.AWS,
154+
"cloud_platform": CLOUD_PLATFORM.AWS_EC2,
155155
},
156156
],
157157
[
158158
200,
159159
bytes(json.dumps(AWS_EC2_EXAMPLE_IMDSv2_PAYLOAD), "utf-8"),
160160
{
161-
"cloud.provider": "aws",
162-
"cloud.platform": "aws_ec2",
163-
"cloud.account.id": "298817902971",
164-
"cloud.availability_zone": "us-east-1b",
165-
"cloud.region": "us-east-1",
166-
"host.id": "i-07d3301297fe0a55a",
167-
"host.type": "t2.small",
161+
"cloud_provider": "aws",
162+
"cloud_platform": "aws_ec2",
163+
"cloud_account_id": "298817902971",
164+
"cloud_availability_zone": "us-east-1b",
165+
"cloud_region": "us-east-1",
166+
"host_id": "i-07d3301297fe0a55a",
167+
"host_type": "t2.small",
168168
},
169169
],
170170
],
@@ -233,27 +233,27 @@ def test_is_gcp_exception():
233233
405,
234234
None,
235235
{
236-
"cloud.provider": CLOUD_PROVIDER.GCP,
237-
"cloud.platform": CLOUD_PLATFORM.GCP_COMPUTE_ENGINE,
236+
"cloud_provider": CLOUD_PROVIDER.GCP,
237+
"cloud_platform": CLOUD_PLATFORM.GCP_COMPUTE_ENGINE,
238238
},
239239
],
240240
[
241241
200,
242242
b"something-but-not-json",
243243
{
244-
"cloud.provider": CLOUD_PROVIDER.GCP,
245-
"cloud.platform": CLOUD_PLATFORM.GCP_COMPUTE_ENGINE,
244+
"cloud_provider": CLOUD_PROVIDER.GCP,
245+
"cloud_platform": CLOUD_PLATFORM.GCP_COMPUTE_ENGINE,
246246
},
247247
],
248248
[
249249
200,
250250
bytes(json.dumps(GCP_GCE_EXAMPLE_METADATA_PLAYLOAD), "utf-8"),
251251
{
252-
"cloud.provider": "gcp",
253-
"cloud.platform": "gcp_compute_engine",
254-
"cloud.account.id": "my-project-internal",
255-
"cloud.availability_zone": "northamerica-northeast2-b",
256-
"host.id": 1535324527892303790,
252+
"cloud_provider": "gcp",
253+
"cloud_platform": "gcp_compute_engine",
254+
"cloud_account_id": "my-project-internal",
255+
"cloud_availability_zone": "northamerica-northeast2-b",
256+
"host_id": 1535324527892303790,
257257
},
258258
],
259259
],

0 commit comments

Comments
 (0)