TestLoggingLinkedWithTrace tests that client and server side logs get the trace and span id corresponding to either the Call Level Span or Server Span (no determinism, so can only assert one or the other), for Unary and Streaming RPCs.
(t *testing.T)
| 847 | // (no determinism, so can only assert one or the other), for Unary and |
| 848 | // Streaming RPCs. |
| 849 | func (s) TestLoggingLinkedWithTrace(t *testing.T) { |
| 850 | fle := &fakeLoggingExporter{ |
| 851 | t: t, |
| 852 | } |
| 853 | oldNewLoggingExporter := newLoggingExporter |
| 854 | defer func() { |
| 855 | newLoggingExporter = oldNewLoggingExporter |
| 856 | }() |
| 857 | |
| 858 | newLoggingExporter = func(context.Context, *config) (loggingExporter, error) { |
| 859 | return fle, nil |
| 860 | } |
| 861 | |
| 862 | idCh := testutils.NewChannel() |
| 863 | |
| 864 | fe := &fakeOpenCensusExporter{ |
| 865 | t: t, |
| 866 | idCh: idCh, |
| 867 | } |
| 868 | oldNewExporter := newExporter |
| 869 | defer func() { |
| 870 | newExporter = oldNewExporter |
| 871 | }() |
| 872 | |
| 873 | newExporter = func(*config) (tracingMetricsExporter, error) { |
| 874 | return fe, nil |
| 875 | } |
| 876 | |
| 877 | const projectID = "project-id" |
| 878 | tracesAndLogsConfig := &config{ |
| 879 | ProjectID: projectID, |
| 880 | CloudLogging: &cloudLogging{ |
| 881 | ClientRPCEvents: []clientRPCEvents{ |
| 882 | { |
| 883 | Methods: []string{"*"}, |
| 884 | MaxMetadataBytes: 30, |
| 885 | MaxMessageBytes: 30, |
| 886 | }, |
| 887 | }, |
| 888 | ServerRPCEvents: []serverRPCEvents{ |
| 889 | { |
| 890 | Methods: []string{"*"}, |
| 891 | MaxMetadataBytes: 30, |
| 892 | MaxMessageBytes: 30, |
| 893 | }, |
| 894 | }, |
| 895 | }, |
| 896 | CloudTrace: &cloudTrace{ |
| 897 | SamplingRate: 1.0, |
| 898 | }, |
| 899 | } |
| 900 | cleanup, err := setupObservabilitySystemWithConfig(tracesAndLogsConfig) |
| 901 | if err != nil { |
| 902 | t.Fatalf("error setting up observability %v", err) |
| 903 | } |
| 904 | defer cleanup() |
| 905 | ss := &stubserver.StubServer{ |
| 906 | UnaryCallF: func(context.Context, *testpb.SimpleRequest) (*testpb.SimpleResponse, error) { |
nothing calls this directly
no test coverage detected