How can I include custom asset observations i.e. r...
# ask-community
g
How can I include custom asset observations i.e. row count into DBT-backed assets? Are there any configuration options I am overlooking?
v
You should be able to use the
runtime_metadata_fn
parameter in
load_assets_from_dbt_*
. I’m not sure if that generates an AssetObservation, but it would add to the metadata returned.
1
a
Some documentation example on how to use
runtime_metadata_fn
for dbt projects would go a long way.
v
c
One option is in your IO manager's
handle_output
method, you could do
context.log_event(AssetObservation(...))
g
Is there any exaple out there? It would be cool of the default docs of dagster could showcase such an example.
c
hmm... our api docs do have a simple example, but it currently isn't displaying correctly: https://docs.dagster.io/_apidocs/io-managers#dagster.OutputContext.log_event Here it is copy pasted:
Copy code
from dagster import IOManager, AssetMaterialization

            class MyIOManager(IOManager):
                def handle_output(self, context, obj):
                    context.log_event(AssetMaterialization("foo"))
I agree that this pattern would be helpful to document in the docs though. We also have a similar utility that attaches observations via the
load_input
method of an IO manager. I'd recommend filing an issue so that we can track adding this to our documentation
g