@@ -57,6 +57,13 @@ func (mm mockMetadata) InstanceID(_ context.Context) (string, error) {
57
57
return "" , nil
58
58
}
59
59
60
+ func (mm mockMetadata ) InstanceLifeCycle (_ context.Context ) (string , error ) {
61
+ if ! mm .isAvailable {
62
+ return "" , errUnavailable
63
+ }
64
+ return "on-demand" , nil
65
+ }
66
+
60
67
func (mm mockMetadata ) Get (_ context.Context ) (imds.InstanceIdentityDocument , error ) {
61
68
if mm .retErrIDDoc != nil {
62
69
return imds.InstanceIdentityDocument {}, mm .retErrIDDoc
@@ -180,6 +187,7 @@ func TestDetector_Detect(t *testing.T) {
180
187
want : func () pcommon.Resource {
181
188
res := pcommon .NewResource ()
182
189
attr := res .Attributes ()
190
+ attr .PutStr ("aws.ec2.instance_life_cycle" , "on-demand" )
183
191
attr .PutStr ("cloud.account.id" , "account1234" )
184
192
attr .PutStr ("cloud.provider" , "aws" )
185
193
attr .PutStr ("cloud.platform" , "aws_ec2" )
@@ -211,6 +219,7 @@ func TestDetector_Detect(t *testing.T) {
211
219
want : func () pcommon.Resource {
212
220
res := pcommon .NewResource ()
213
221
attr := res .Attributes ()
222
+ attr .PutStr ("aws.ec2.instance_life_cycle" , "on-demand" )
214
223
attr .PutStr ("cloud.account.id" , "account1234" )
215
224
attr .PutStr ("cloud.provider" , "aws" )
216
225
attr .PutStr ("cloud.platform" , "aws_ec2" )
@@ -244,6 +253,7 @@ func TestDetector_Detect(t *testing.T) {
244
253
want : func () pcommon.Resource {
245
254
res := pcommon .NewResource ()
246
255
attr := res .Attributes ()
256
+ attr .PutStr ("aws.ec2.instance_life_cycle" , "on-demand" )
247
257
attr .PutStr ("cloud.account.id" , "account1234" )
248
258
attr .PutStr ("cloud.provider" , "aws" )
249
259
attr .PutStr ("cloud.platform" , "aws_ec2" )
0 commit comments