openlangrid / langrid

Service Grid Server Software - Language Grid Base System
2 stars 2 forks source link

Log details of service invocation from composite services and provide it only to caller. #27

Open takawitter opened 9 years ago

takawitter commented 9 years ago

https://github.com/openlangrid/langrid/commit/b74e6fe3b63ac9a8819916fc67325a456d5edc8b https://github.com/openlangrid/langrid/commit/c0951005050dd7860b2aff803e14a837e077da95 Add rpc header: X-ServiceGrid-ServiceContainer-GatherInvocationLog to enable invocation logging on service container. You can use it with the header X-ServiceGrid-TransferToEndpoint- to pass that header to service container like:

    TranslationWithTemporalDictionaryService s = Context.createSoapClient(
            getClass(),
            TranslationWithTemporalDictionaryService.class,
            new BindingNode("TranslationPL", "KyotoUJServer"),
            new BindingNode("MorphologicalAnalysisPL", "TreeTagger")
        );
    ((RequestAttributes)s).addRequestMimeHeader(
            LangridConstants.HTTPHEADER_TRANSFER_TO_ENDPOINT +
            LangridConstants.HTTPHEADER_SERVICECONTAINER_GATAHER_INVOCATION_LOG,
            "true");
    Assert.assertTrue(s.translate("en", "ja", "hello", new Translation[]{}, "ja").length() > 0);
    for(RpcHeader h : ((ResponseAttributes)s).getResponseRpcHeaders()){
        if(h.getName().equals("log")){
            System.out.println("-- gathered logs --");
            System.out.print(h.getValue());
            System.out.println("----");
        }
    }
takawitter commented 9 years ago

Take hierarchical invocation of composite services into account.