Terraform telemetry at the provider level ( like number of resources currently being used )

I have a provider x, and i define 3 resources in my .tf file. For telemetry purpose i want to know how many resources are being used in my .tf file at the provider level code ( i.e., provider.go ).

Is there any available option to get the resource telemetry data in terraform ?

I do can get the resource names whenever code touches the resource level code, but i am interested at the provider level to get the current resource usage without going to the resource level code.

The provider does not get this kind of information via the Terraform plugin protocol.

The way people writing Terraform providers typically find this kind of information is by having a Terraform User-Agent header attached to upstream calls to the service provider / upstream API. Then the upstream API can look at its statistics in request history and see X requests were performed by the Terraform User-Agent, and attribute that usage to a Terraform user, etc.

1 Like