public static ProjectName parse(String formattedString) { if (formattedString.isEmpty()) { return null; } Map<String, String> matchMap = PATH_TEMPLATE.validatedMatch( formattedString, "ProjectName.parse: formattedString not in valid format"); return of(matchMap.get("project")); }
public static List<ProjectName> parseList(List<String> formattedStrings) { List<ProjectName> list = new ArrayList<>(formattedStrings.size()); for (String formattedString : formattedStrings) { list.add(parse(formattedString)); } return list; }
public static String format(String project) { return newBuilder().setProject(project).build().toString(); }
@Test @SuppressWarnings("all") public void batchWriteSpansTest() { Empty expectedResponse = Empty.newBuilder().build(); mockTraceService.addResponse(expectedResponse); ProjectName name = ProjectName.of("[PROJECT]"); List<Span> spans = new ArrayList<>(); client.batchWriteSpans(name, spans); List<GeneratedMessageV3> actualRequests = mockTraceService.getRequests(); Assert.assertEquals(1, actualRequests.size()); BatchWriteSpansRequest actualRequest = (BatchWriteSpansRequest) actualRequests.get(0); Assert.assertEquals(name, ProjectName.parse(actualRequest.getName())); Assert.assertEquals(spans, actualRequest.getSpansList()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
public static List<String> toStringList(List<ProjectName> values) { List<String> list = new ArrayList<String>(values.size()); for (ProjectName value : values) { if (value == null) { list.add(""); } else { list.add(value.toString()); } } return list; }
public ProjectName build() { return new ProjectName(this); } }
public String getFieldValue(String fieldName) { return getFieldValuesMap().get(fieldName); }
public static ProjectName of(String project) { return newBuilder().setProject(project).build(); }
/** * Sends new spans to new or existing traces. You cannot update existing spans. * * <p>Sample code: * * <pre><code> * try (TraceServiceClient traceServiceClient = TraceServiceClient.create()) { * ProjectName name = ProjectName.of("[PROJECT]"); * List<Span> spans = new ArrayList<>(); * traceServiceClient.batchWriteSpans(name, spans); * } * </code></pre> * * @param name Required. The name of the project where the spans belong. The format is * `projects/[PROJECT_ID]`. * @param spans A list of new spans. The span names must not match existing spans, or the results * are undefined. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final void batchWriteSpans(ProjectName name, List<Span> spans) { BatchWriteSpansRequest request = BatchWriteSpansRequest.newBuilder() .setName(name == null ? null : name.toString()) .addAllSpans(spans) .build(); batchWriteSpans(request); }
public ProjectName build() { return new ProjectName(this); } }
public String getFieldValue(String fieldName) { return getFieldValuesMap().get(fieldName); }
public static ProjectName of(String project) { return newBuilder().setProject(project).build(); }
public static void executeNoCatch(String projectId) throws Exception { try (TraceServiceClient client = TraceServiceClient.create()) { ProjectName name = ProjectName.of(projectId); List<Span> spans = new ArrayList<>(); client.batchWriteSpans(name, spans); } }
public static String format(String project) { return newBuilder().setProject(project).build().toString(); }
public static List<String> toStringList(List<ProjectName> values) { List<String> list = new ArrayList<String>(values.size()); for (ProjectName value : values) { if (value == null) { list.add(""); } else { list.add(value.toString()); } } return list; }
public static List<ProjectName> parseList(List<String> formattedStrings) { List<ProjectName> list = new ArrayList<>(formattedStrings.size()); for (String formattedString : formattedStrings) { list.add(parse(formattedString)); } return list; }
@Test @SuppressWarnings("all") public void batchWriteSpansExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockTraceService.addException(exception); try { ProjectName name = ProjectName.of("[PROJECT]"); List<Span> spans = new ArrayList<>(); client.batchWriteSpans(name, spans); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } } }
public static ProjectName parse(String formattedString) { if (formattedString.isEmpty()) { return null; } Map<String, String> matchMap = PATH_TEMPLATE.validatedMatch( formattedString, "ProjectName.parse: formattedString not in valid format"); return of(matchMap.get("project")); }
private StackdriverV2ExporterHandler( String projectId, TraceServiceClient traceServiceClient, @javax.annotation.Nullable Map<String, io.opencensus.trace.AttributeValue> fixedAttributes) { this.projectId = checkNotNull(projectId, "projectId"); this.traceServiceClient = traceServiceClient; if (fixedAttributes == null) { this.fixedAttributes = Collections.emptyMap(); } else { this.fixedAttributes = new HashMap<>(); for (Map.Entry<String, io.opencensus.trace.AttributeValue> label : fixedAttributes.entrySet()) { AttributeValue value = toAttributeValueProto(label.getValue()); if (value != null) { this.fixedAttributes.put(label.getKey(), value); } } } projectName = ProjectName.of(this.projectId); }
private StackdriverV2ExporterHandler( String projectId, TraceServiceClient traceServiceClient, @javax.annotation.Nullable Map<String, io.opencensus.trace.AttributeValue> fixedAttributes) { this.projectId = checkNotNull(projectId, "projectId"); this.traceServiceClient = traceServiceClient; if (fixedAttributes == null) { this.fixedAttributes = Collections.emptyMap(); } else { this.fixedAttributes = new HashMap<>(); for (Map.Entry<String, io.opencensus.trace.AttributeValue> label : fixedAttributes.entrySet()) { AttributeValue value = toAttributeValueProto(label.getValue()); if (value != null) { this.fixedAttributes.put(label.getKey(), value); } } } projectName = ProjectName.of(this.projectId); }