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

pdata.AttributeValue.IsNil() always returns false #2188

Closed
hossain-rayhan opened this issue Nov 20, 2020 · 0 comments · Fixed by #2192
Closed

pdata.AttributeValue.IsNil() always returns false #2188

hossain-rayhan opened this issue Nov 20, 2020 · 0 comments · Fixed by #2192
Labels
bug Something isn't working

Comments

@hossain-rayhan
Copy link
Contributor

hossain-rayhan commented Nov 20, 2020

So, the problem is, I want to write a unit_test for checking if pdata.AttributeValue.IsNil() but I can't.

I tried to use attributeMap.InsertNull("key") and the func NewAttributeValueNull() to create a Nil pdata.AttributeValue but they didn't work. Every-time I call pdata.AttributeValue.IsNil() it returns false. I feel something is wrong with these set of functions. I tried the following two ways. None of them worked to assign a Nil AttributeValue in a pdata.AttributeMap.

Example-1:

        attributeMap := pdata.NewAttributeMap()
	attributeMap.InsertNull("ClusterName")

	if v, ok := attributeMap.Get("ClusterName"); ok {
		if v.IsNil() {
			fmt.Println("Nil Assigned") // Never comes here
		} else {
			fmt.Println("Not Nil")
		}
	}

Example-2:

        attributeMap := pdata.NewAttributeMap()
	attributeMap.InitEmptyWithCapacity(1)
        attributeMap.Insert("ClusterName", pdata.NewAttributeValueNull())

	if v, ok := attributeMap.Get("ClusterName"); ok {
		if v.IsNil() {
			fmt.Println("Nil Assigned") // Never comes here
		} else {
			fmt.Println("Not Nil")
		}
	}
@hossain-rayhan hossain-rayhan added the bug Something isn't working label Nov 20, 2020
MovieStoreGuy pushed a commit to atlassian-forks/opentelemetry-collector that referenced this issue Nov 11, 2021
* Deprecate the oteltest package

* Add PR number to changes in changelog

* Ignore oteltest deprecation in oteltest
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant